package com.ruoyi.web.controller.prevention;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.entity.PreventionHiddenInventory;
import com.ruoyi.system.service.PreventionHiddenInventoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

/**
 * 隐患清单(PreventionHiddenInventory)表控制层
 * @since 2023-04-13 09:39:44
 */
@RestController
@Api("隐患清单接口")
@RequestMapping("preventionHiddenInventory")
public class PreventionHiddenInventoryController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private PreventionHiddenInventoryService preventionHiddenInventoryService;

    /**
     * 分页查询
     * @return 查询结果
     */
    @GetMapping
    @ApiOperation("隐患清单")
    public TableDataInfo queryByPage(PreventionHiddenInventory preventionHiddenInventory) {
        startPage();
        List<PreventionHiddenInventory> inventoryList = preventionHiddenInventoryService.queryByPage(preventionHiddenInventory);
        return getDataTable(inventoryList);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public ResponseEntity<PreventionHiddenInventory> queryById(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(this.preventionHiddenInventoryService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param preventionHiddenInventory 实体
     * @return 新增结果
     */
    @PostMapping
    public ResponseEntity<PreventionHiddenInventory> add(PreventionHiddenInventory preventionHiddenInventory) {
        return ResponseEntity.ok(this.preventionHiddenInventoryService.insert(preventionHiddenInventory));
    }

    /**
     * 编辑数据
     *
     * @param preventionHiddenInventory 实体
     * @return 编辑结果
     */
    @PutMapping
    public ResponseEntity<PreventionHiddenInventory> edit(PreventionHiddenInventory preventionHiddenInventory) {
        return ResponseEntity.ok(this.preventionHiddenInventoryService.update(preventionHiddenInventory));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(Integer id) {
        return ResponseEntity.ok(this.preventionHiddenInventoryService.deleteById(id));
    }

}

